Docs Site Creation
Prerequisites#
A domain with DNS through Cloudflare
A GitHub account
Install NPM and yarn
Create a template site#
Open a terminal in your GitHub directory
install Docusaurus and run it for the first time to generate template files:
yarn add docusaurusnpx @docusaurus/init@latest init my-website classicStart a demo server to make sure the site runs:
cd my-websiteyarn startMake a new git repository and upload it to GitHub
in GitHub desktop you can use File -> New Repository
no need to make a
.gitignoreorreadme.md, they will already be generatedNOTE: if you make this repository private (or plan on password-protecting the site) it may have implications on search functionality... but I did both anyway)
Add site to Cloudflare Pages#
In the Cloudflare dashboard, go to pages, then create a project.
Link your GitHub account
Select the repository you just made
Under framework preset, select Docusaurus, then you can Save and Deploy
Wait for the site to build
Under custom domains you can deploy your site to a domain or subdomain of your choosing and Cloudflare will automatically update your DNS records
Add password protection to your custom domain#
NOTE: if you do this you will need to set up your own search scraper (or not use search)
In the Cloudflare dashboard, select your domain, then go to workers, then manage workers
Create a new worker and name it
Copy the password protection code from GitHub - dommmel/cloudflare-workers-basic-auth: Basic http auth via cloudflare workers and paste it into the left box
- IMPORTANT: don't forget to change the credentials in index.js before saving!
Go back to your domain's worker page in the Cloudflare dashboard, and select add route
If you are using the entire domain for this site than you can use the default of
*.my-domain.com/*- if you are using a subdomain, use
subdomain.my-domain.com/*
- if you are using a subdomain, use
Select the worker you just made
Save
Test and make sure the password protection is working